home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.001 / crossfir~ / eutl / dynarray / dynarray.h < prev    next >
C/C++ Source or Header  |  1994-10-15  |  2KB  |  60 lines

  1. #ifndef __eutl_dynarray_h
  2. #define __eutl_dynarray_h
  3.  
  4. /* exceptions are used. */
  5. extern char *dynarray_packagever;
  6. extern char *dynarray_Ebadisize;
  7. extern char *dynarray_Eoutofbounds;
  8.  
  9. /* Usually, just the part after eutl_dynarray_ would be used to call these
  10.    functions, as generated by the defines tested on __eutl_dynarray_impl */
  11.  
  12. typedef struct __eutl_dynarray_DynArray *eutl_dynarray_DynArray;
  13.  
  14. /* item size, initial item count, item count increment 
  15.    the default will set the initial number an increment such that
  16.    about EUTL_DYNARRAY_MEMCHUNK bytes are used for each increment, 
  17.    with a minimum increment of EUTL_DYNARRAY_MININCR */
  18.  
  19. #define EUTL_DYNARRAY_MEMCHUNK 512
  20. #define EUTL_DYNARRAY_MININCR 10
  21.    
  22. eutl_dynarray_DynArray eutl_dynarray_dyn_create(unsigned int itemsize,
  23.                   unsigned int initialnum,/* 0 for default */
  24.                   unsigned int itemincr); /* 0 for default. */
  25. void eutl_dynarray_dyn_destroy(eutl_dynarray_DynArray gone);
  26.  
  27. void eutl_dynarray_dyn_set(eutl_dynarray_DynArray array,
  28.                unsigned int index,
  29.                void *iptr); /* pointer to item */
  30. void *eutl_dynarray_dyn_get(eutl_dynarray_DynArray array,
  31.                 unsigned int index);
  32.  
  33. /* dyn_set and dyn_get would be used like:
  34.    {
  35.    int x,y,z;
  36.    DynArray arr = eutl_dynarray_dyn_create(sizeof(int),0,0);
  37.    x = 5;y=7;z=8;
  38.    dyn_set(arr,2,&x); // arr[2] = 5 
  39.    y = *(int *)dyn_get(arr,2); // y = 5 
  40.    dyn_set(arr,0,&z); // arr[0] = 8
  41.    y = *(int *)dyn_get(arr,1); // y = unknown
  42.    y = *(int *)dyn_get(arr,5); // dynarray_EOutOfBounds thrown
  43. */
  44.  
  45. #ifndef __eutl_dynarray_impl
  46. /* This will convert short exported symbols to 
  47.    the long symbols used in the eutl implementation.
  48.    This reduces the chance of a collision in the symbol table while 
  49.    linking, but doesn't force the programmer to use obnoxiously long
  50.    names (they are still available) */
  51.  
  52. #define DynArray eutl_dynarray_DynArray
  53. #define dyn_create eutl_dynarray_dyn_create
  54. #define dyn_set eutl_dynarray_dyn_set
  55. #define dyn_get eutl_dynarray_dyn_get
  56. #define dyn_destroy eutl_dynarray_dyn_destroy
  57. #endif
  58.  
  59. #endif
  60.